using Microsoft.AspNetCore.Mvc;
using MyMes.Dto;
using MyMES.IServices.ArrivalNotices;
using System.Threading.Tasks;
using VOL.Core.Controllers.Basic;
using VOL.Core.Filters;
using VOL.Core.Utilities;
using VOL.Core.Utilities.Response;
using VOL.Entity.AttributeManager;
using VOL.Entity.DomainModels;
using VOL.Entity.DomainModels.Core;
using VOL.Entity.DomainModels.Repository;

namespace VOL.WebApi.Controllers
{
    /// <summary>
    /// 到货通知单控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ArrivalNoticeController : ApiBaseController<IArrivalNoticeService>
    {
        private readonly IArrivalNoticeService _arrivalNoticeService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="service">到货通知单服务</param>
        public ArrivalNoticeController(IArrivalNoticeService service)
            : base(service)
        {
            _arrivalNoticeService = service;
        }

        /// <summary>
        /// 获取到货通知单列表
        /// </summary>
        /// <param name="dto">查询条件</param>
        /// <returns>分页后的到货通知单列表</returns>
        [HttpPost("GetArrivalNoticeList")]
        public async Task<ActionResult<PageGridData<ArrivalNoticeListDto>>> GetList([FromBody] GetArrivalNoticeDto dto)
        {
            return await _arrivalNoticeService.GetShipmentsModelList(dto);
        }

        /// <summary>
        /// 新增到货通知单
        /// </summary>
        /// <param name="arrivalNotice">到货通知单实体</param>
        /// <returns>操作结果</returns>
        [HttpPost("AddArrivalNotice")]
        public async Task<ActionResult<WebResponseContent>> Add([FromBody] ArrivalNotice arrivalNotice)
        {
            return await _arrivalNoticeService.CreateShipmentsModel(arrivalNotice);
        }

        /// <summary>
        /// 更新到货通知单
        /// </summary>
        /// <param name="arrivalNotice">到货通知单实体</param>
        /// <returns>操作结果</returns>
        [HttpPost("UpdateArrivalNotice")]
        public async Task<ActionResult<WebResponseContent>> Update([FromBody] ArrivalNotice arrivalNotice)
        {
            return await _arrivalNoticeService.UpdateShipmentsModel(arrivalNotice);
        }

        /// <summary>
        /// 批量删除到货通知单
        /// </summary>
        /// <param name="dto">包含以逗号分隔的ID字符串的DTO</param>
        /// <returns>操作结果</returns>
        [HttpPost("BatchDeleteArrivalNotice")]
        public async Task<ActionResult<WebResponseContent>> BatchDelete([FromBody] string ids)
        {
            return await _arrivalNoticeService.DelShipments(ids);
        }
    }
}